package com.team9.fitness.service;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Service;

import com.team9.fitness.service.ZRDDSDataExchangeService;

/**
 * 系统初始化服务
 * 负责系统启动时的初始化工作
 */
@Service
public class SystemInitializationService implements CommandLineRunner {

    private static final Logger log = LoggerFactory.getLogger(SystemInitializationService.class);

    @Autowired
    private ZRDDSDataExchangeService zrddsDataExchangeService;

    @Override
    public void run(String... args) throws Exception {
        log.info("开始系统初始化...");

        try {
            // 订阅ZRDDS主题
            zrddsDataExchangeService.subscribeAllTopics();
            log.info("ZRDDS主题订阅完成");

            log.info("系统初始化完成");

        } catch (Exception e) {
            log.error("系统初始化失败", e);
            throw e;
        }
    }
}
